const ble = require('../../../utils/ble');

Page({
  data: { list: [] },
  async onLoad() {
    try { await ble.init(); } catch (_e) {}
  },
  async scan() {
    wx.showLoading({ title: '扫描中' });
    try {
      const list = await ble.startScan(5000);
      // 可在这里按名称前缀过滤特定设备
      this.setData({ list });
    } finally { wx.hideLoading(); }
  },
  choose(e) {
    const { id, name } = e.currentTarget.dataset;
    wx.navigateTo({ url: `/pages/provision/wifi/wifi?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}` });
  }
});


